<# # It is recommended to test the script on a local machine for its purpose and effects. # ManageEngine Endpoint Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description: Script is designed To copy folder from one share path to another share path # Configuration Type - COMPUTER # Limitation: The source and destination both share path needs access to everyone in that scenario only the script will works as expected. #> #Hardcode the sharepath value here $sourceFolder = "\\sharepath1" $destinationFolder = "\\sharepath2" $logFolder = "C:\Endpointcentral" $logFile = "$logFolder\copy_logs.txt" # Create log folder if it doesn't exist if (!(Test-Path $logFolder)) { New-Item -Path $logFolder -ItemType Directory -Force | Out-Null } # Copy the folder and log any anomalies try { robocopy $sourceFolder $destinationFolder /e /log+:$logFile /np /ndl /njh /njs Write-Output "Folder copied successfully." } catch { # Log the error $errorMessage = "Error occurred during copying: $_" Write-Output $errorMessage Add-content -Path $logFile -Value $errorMessage }